package com.wicket.okrcomponent.biz.service.nb;

import cn.hutool.core.bean.BeanUtil;
import com.wicket.okrcomponent.biz.service.dto.common.ComDatasDto;
import com.wicket.okrcomponent.common.util.CommonFunctionHelper;
import org.apache.skywalking.apm.toolkit.trace.Tag;
import org.apache.skywalking.apm.toolkit.trace.Tags;
import org.apache.skywalking.apm.toolkit.trace.Trace;
import org.springframework.stereotype.Service;
import com.wicket.okrcomponent.biz.service.dto.req.ImplementSingleSetDataEntryReqDto;
import com.wicket.okrcomponent.biz.service.dto.res.ImplementSingleSetDataEntryRespDto;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

import com.wicket.okrcomponent.biz.service.dto.req.ImplementSingleMultipleFieldSetDataEntryReqDto;
import com.wicket.okrcomponent.biz.service.dto.res.ImplementSingleMultipleFieldSetDataEntryRespDto;

/**
 * @author ： 手工接入方法
 * @since 2022/5/28 15:32
 *
 *
 * @version 1.0
 */
@Service
public class NbDataSetSingleEntry {
/**
      * code:objectToData
      * name:M2执行单条转数据集
      * desc:undefined
      * gen by moon at 5/18/2024, 7:24:01 PM
      * 
      **/
     @Trace(operationName = "M2执行单条转数据集")
     @Tags({@Tag(key = "参数",value = "arg[0]"),
     @Tag(key = "返回值",value = "returnedObj")})
      public ImplementSingleSetDataEntryRespDto implementSingleSetDataEntry(ImplementSingleSetDataEntryReqDto reqDto) {
         ImplementSingleSetDataEntryRespDto retData = new ImplementSingleSetDataEntryRespDto();
         List<String> datas = Arrays.asList(reqDto.getDatasetField().split(","));
         List<String> newDatas = new ArrayList<>();
         for (String one : datas){
             newDatas.add(CommonFunctionHelper.getFilePath(one));
         }
         retData.setSingleSetDataEntryList(newDatas);
        return retData;
      }
/**
      * code:objectToData
      * name:M2执行单条多字段转数据集（特殊方法）
      * desc:undefined
      * gen by moon at 6/8/2024, 8:05:40 PM
      *
      **/
     @Trace(operationName = "M2执行单条多字段转数据集（特殊方法）")
     @Tags({@Tag(key = "参数",value = "arg[0]"),
     @Tag(key = "返回值",value = "returnedObj")})
      public ImplementSingleMultipleFieldSetDataEntryRespDto implementSingleMultipleFieldSetDataEntry(ImplementSingleMultipleFieldSetDataEntryReqDto reqDto) {
         ImplementSingleMultipleFieldSetDataEntryRespDto retData = new ImplementSingleMultipleFieldSetDataEntryRespDto();
         List<ImplementSingleMultipleFieldSetDataEntryReqDto> reqList = new ArrayList<>();
         reqList.add(reqDto);
         retData.setComDatasList(reqList.stream().map(p->{
             ComDatasDto elm = new ComDatasDto();
             BeanUtil.copyProperties(p,elm);
             return elm;
         }).collect(Collectors.toList()));
        return retData;
      }
  //手工接入方法
}
